package com.yantu.controller.student;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yantu.bean.MessageUser;
import com.yantu.mapper.MessageUserMapper;
import com.yantu.util.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@ApiModel("未读消息数量接口")
public class StudentMessageUnreadCountController {
    @Autowired
    MessageUserMapper messageUserMapper;

    @GetMapping("/messageUnreadCount/{id}")
    @ApiOperation("未读消息数量")
    public Result messageUnreadCount(@PathVariable("id") Integer id) {

        QueryWrapper<MessageUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("receive_user_id",id);
        queryWrapper.eq("readed",false);
        List<MessageUser> messageUsers = messageUserMapper.selectList(queryWrapper);

        return Result.succ(200,"查询成功",messageUsers.size());

    }
}
